package com.imooc.order.controller;



import com.imooc.order.ClientFeign.ProductClient;
import com.imooc.order.common.DecreaseStockInput;
import com.imooc.order.common.ProductInfoOutput;
import com.imooc.order.dataobject.ProductInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
public class ClientFeignController {

    @Autowired
    ProductClient productClient ;


    @GetMapping("getProductMsg")
    public String  getProductMsg(){

        String response = productClient.getProductMsg();

        return  response ;


    }


    @GetMapping("/getProductList")
    public String getProductList(){
       List<ProductInfoOutput> list  = productClient.listForOrder(Arrays.asList("164103465734242707"));

        System.out.println(list);

        return "ok";

    }


    @GetMapping("/decreaseStock")
    public   String  decreaseStock(){
        DecreaseStockInput  in = new DecreaseStockInput("164103465734242707",2);
        productClient.descreaseStock(Arrays.asList(in));

        return "ok" ;
    }



}
